﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BidFunLib.BidWeb;
using BidFunLib.Entity;
using BidFunLib.Services;
using BidFunLib.BidWeb.Sale;
using BidFunSpy.BidWeb;

namespace BidFunSpy
{
    public partial class BidsHistory : Form
    {
        public BidsHistory(BidWebRootSpy manager)
        {

            InitializeComponent();
            listView1.Items.Clear();
            foreach (StatsBidSale stats in manager.StatsList)
            {
                BidSale sale  =BidSaleManager.Instance.getBidSaleById(stats.IdBidSale);
                ListViewItem item = new ListViewItem();
                item.Text = sale.BidObject.Label;
                item.SubItems.Add(sale.BidFunIdentifier);
                item.SubItems.Add(stats.Amount.ToString());
                item.SubItems.Add(new DateTime(sale.VerificationLapseTimeTick).Second.ToString());   
                BidUser user = BidUserManager.Instance.getUserById(stats.IdBidUser);
                item.SubItems.Add(user.Pseudo);
                item.SubItems.Add(stats.NbPointsPaidByWinner.ToString());

                item.SubItems.Add(stats.WinDateTime.ToString());
                item.SubItems.Add(stats.SaleDurationInSeconds.ToString());
                item.SubItems.Add((stats.NbBidsManual + stats.NbBidsByBot).ToString());
                item.SubItems.Add(stats.NbBidsManual.ToString());
                item.SubItems.Add(stats.NbBidsByBot.ToString());
                
                listView1.Items.Add(item);
            }
        }
    }
}
